// let mongoose = require('mongoose')
let mysql = require('mysql')
let {dbpath} = require('../config/config')
// exports.connect = function (){
//     mongoose.connect(dbpath,() => console.log('数据库连接成功~~'))
// }
const conn = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    port: 3306,
    password: 'root',
    database: 'mtest'
})
exports.connect = function (){
    conn.connect((err)=>{
        console.log(err);
        if(err){
        // 抛出异常
            console.log('数据库连接失败');
        }else{
            console.log('数据库连接成功~~')
        }
    })
}
exports.conn = conn